import React from 'react'
export default class App extends React.Component {
  state = {
    count: 0,
  }
  render() {
    return (
      <div>
        <h1>父组件:{this.state.count}</h1>
        <Son title={'美食'}></Son>
      </div>
    )
  }
  componentDidMount() {
    console.log('componentDidMount钩子被执行了')
  }
}

class Son extends React.Component {
  state = {
    count: 0,
  }
  render() {
    return (
      <div>
        <h1>父组件：{this.props.title}</h1>
        <h2>{this.state.count}</h2>
      </div>
    )
  }
  componentDidMount() {
    console.log('componentDidMount钩子被执行了')
    // setInterval(() => {
    //   this.setState({ count: this.state.count + 1 })
    // }, 10)
    // 在componentDiaMount里面写定时器，不在render里面写
  }
}
